package com.ruoyi.yf.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.domain.SysDistricts;
import com.ruoyi.yf.domain.YfHospitalStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.yf.mapper.YfStorageWarningMapper;
import com.ruoyi.yf.domain.YfStorageWarning;
import com.ruoyi.yf.service.IYfStorageWarningService;
import com.ruoyi.common.core.text.Convert;

/**
 * 院内医废预警量配置Service业务层处理
 *
 */
@Service
public class YfStorageWarningServiceImpl implements IYfStorageWarningService 
{
    @Autowired
    private YfStorageWarningMapper yfStorageWarningMapper;

    /**
     * 查询院内医废预警量配置
     * 
     * @param id 院内医废预警量配置ID
     * @return 院内医废预警量配置
     */
    @Override
    public YfStorageWarning selectYfStorageWarningById(Long id)
    {
        return yfStorageWarningMapper.selectYfStorageWarningById(id);
    }

    /**
     * 查询院内医废预警量配置列表
     * 
     * @param yfStorageWarning 院内医废预警量配置
     * @return 院内医废预警量配置
     */
    @Override
    public List<YfStorageWarning> selectYfStorageWarningList(YfStorageWarning yfStorageWarning)
    {
        return yfStorageWarningMapper.selectYfStorageWarningList(yfStorageWarning);
    }


    /**
     * 查询院内所有医废类型预警量配置列表
     *
     */
    @Override
    public List<YfStorageWarning> selectYfTypeStorageWarningList(YfStorageWarning yfStorageWarning) {
        return yfStorageWarningMapper.selectYfTypeStorageWarningList(yfStorageWarning);
    }

    /**
     * 新增院内医废预警量配置
     * 
     * @param yfStorageWarning 院内医废预警量配置
     * @return 结果
     */
    @Override
    public int insertYfStorageWarning(YfStorageWarning yfStorageWarning)
    {
        yfStorageWarning.setCreateTime(DateUtils.getNowDate());
        return yfStorageWarningMapper.insertYfStorageWarning(yfStorageWarning);
    }

    /**
     * 修改院内医废预警量配置
     * 
     * @param yfStorageWarning 院内医废预警量配置
     * @return 结果
     */
    @Override
    public int updateYfStorageWarning(YfStorageWarning yfStorageWarning)
    {
        yfStorageWarning.setUpdateTime(DateUtils.getNowDate());
        return yfStorageWarningMapper.updateYfStorageWarning(yfStorageWarning);
    }

    /**
     * 删除院内医废预警量配置对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteYfStorageWarningByIds(String ids)
    {
        return yfStorageWarningMapper.deleteYfStorageWarningByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除院内医废预警量配置信息
     * 
     * @param id 院内医废预警量配置ID
     * @return 结果
     */
    @Override
    public int deleteYfStorageWarningById(Long id)
    {
        return yfStorageWarningMapper.deleteYfStorageWarningById(id);
    }

    /**
     * 根据医院id查询医院暂存点
     * @return
     */
    @Override
    public List<SysDept> getStangsByHospitalId(Long hospitalId) {
        return yfStorageWarningMapper.getStangsByHospitalId(hospitalId);
    }


    /**
     * 查询登录用户所在机构的地区的下辖区县
     */
    @Override
    public List<SysDistricts> getCountyByDistrictsId(String flag, Integer districtsId) {
        return yfStorageWarningMapper.getCountyByDistrictsId(flag, districtsId);
    }


    /**
     * 医院暂存点状况
     */
    @Override
    public List<YfHospitalStatus> hospitalStatusList(Long deptId,YfHospitalStatus yfHospitalStatus) {
        return yfStorageWarningMapper.hospitalStatusList(deptId,yfHospitalStatus);
    }

    /**
     * 单个医院暂存点状况
     */
    @Override
    public List<YfHospitalStatus> hospitalStatus(Long deptId) {
        return yfStorageWarningMapper.hospitalStatus(deptId);
    }

    /**
     * 获取医院
     */
    @Override
    public List<SysDept> getHospital(Long deptId) {
        return yfStorageWarningMapper.getHospital(deptId);
    }

    /**
     * 院内超期未录入配置列表
     */
    @Override
    public List<YfHospitalStatus> hospitalOverdueNotinputList(Long deptId, String selectType, YfHospitalStatus yfHospitalStatus) {
        return yfStorageWarningMapper.hospitalOverdueNotinputList(deptId, selectType, yfHospitalStatus);
    }


    /**
     * 预警开关修改
     */
    @Override
    public int changeOverdueNotinputSwitchStatus(Long stagingId, String status) {
        return yfStorageWarningMapper.changeOverdueNotinputSwitchStatus(stagingId,status);
    }


    /**
     * 修改超期未录入预警
     */
    @Override
    public int updateOverdueNotinput(SysDept sysDept) {
        return yfStorageWarningMapper.updateOverdueNotinput(sysDept);
    }


    // 根据暂存点查询超过48小时未出库的科室
    @Override
    public String getKsNamesByStangId(Long stagingId) {
        return yfStorageWarningMapper.getKsNamesByStangId(stagingId);
    }


    // 市卫健委及以上，辖区内各医院暂存点状况
    @Override
    public List<YfHospitalStatus> districtsWarnStatusList(Long disId) {
        return yfStorageWarningMapper.districtsWarnStatusList(disId);
    }

    // 市卫健委及以上，辖区内各医院暂存点状况（只包括科室类型为10产生的医废）
    @Override
    public List<YfHospitalStatus> districtsCityHospitalInDeptWarnStatusList(Long disId) {
        return yfStorageWarningMapper.districtsCityHospitalInDeptWarnStatusList(disId);
    }

    // 添加科室中的医疗机构（统计科室，无需合并暂存点）
    @Override
    public List<YfHospitalStatus> districtsCityHospitalInKSWarnStatusList(Long disId) {
        return yfStorageWarningMapper.districtsCityHospitalInKSWarnStatusList(disId);
    }


    // 区县级卫健局 -- 显示区县级卫健局下辖医院预警状况（统计到暂存点）
    @Override
    public List<YfHospitalStatus> districtsHospitalWarnStatusList(Long disId) {
        return yfStorageWarningMapper.districtsHospitalWarnStatusList(disId);
    }

    // 区县级卫健局，辖区内各医院暂存点状况（只包括科室类型为10产生的医废）
    @Override
    public List<YfHospitalStatus> districtsCountyHospitalInDeptWarnStatusList(Long disId) {
        return yfStorageWarningMapper.districtsCountyHospitalInDeptWarnStatusList(disId);
    }

    // 区县级卫健局，添加科室中的医疗机构（统计科室，无需合并暂存点）
    @Override
    public List<YfHospitalStatus> districtsCountyHospitalInKSWarnStatusList(Long disId) {
        return yfStorageWarningMapper.districtsCountyHospitalInKSWarnStatusList(disId);
    }


    // 机构层级权限内各医院暂存点状况（科室类型为10的医废）
    @Override
    public List<YfHospitalStatus> deptHospitalInDeptWarnStatusList(Long deptId) {
        return yfStorageWarningMapper.deptHospitalInDeptWarnStatusList(deptId);
    }

    // 机构层级权限内各医院的科室中的医疗机构状况（科室类型20到50，无需合并暂存点）
    @Override
    public List<YfHospitalStatus> deptHospitalInKSWarnStatusList(Long deptId) {
        return yfStorageWarningMapper.deptHospitalInKSWarnStatusList(deptId);
    }

}
